#include <stdio.h>
#include <string.h>

main()
{
	int n,k;
	int tot,rest;
	while (scanf("%d%d", &n, &k)!=EOF)
	{
		tot=0;
		rest=0;
		while (!(n==0 && rest<k))
		{
			tot+=n;
			rest+=n;
			n=rest/k;
			rest=rest%k;			

			//		printf("%d %d\n", n,rest);
			
		}
		printf("%d\n",tot);
	}

	return 0;
}